//
//  PLTextField.h
//
//  Created by KimmanYip on 2017/9/24.
//
//

/*
 * 自定义TextField
 */

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, PLTextFieldState) {
    PLTextFieldStateNormal = 0,
    PLTextFieldStateEditing,
    PLTextFieldStateError,
};

@interface PLTextField : UIView

#pragma mark - text : 输入文字相关

@property(nullable, nonatomic, readonly, copy) NSString     *text;

/**
 输入控件
 */
@property (nullable, nonatomic, strong) UITextField       *textField;

/**
 默认为nil,用不透明黑色
 */
@property (nullable, nonatomic, strong) UIColor     *textColor;

/**
 默认为nil,用系统12号字体
 */
@property (nullable, nonatomic, strong) UIFont    *font;

/**
 清除按钮模式，默认为UITextFieldViewModeNever
 */
@property (nonatomic) UITextFieldViewMode  clearButtonMode;

/**
 UITextField左边的视图
 */
@property(nullable, nonatomic,strong) UIView     *leftView;        // e.g. magnifying glass

@property(nonatomic)        UITextFieldViewMode  leftViewMode;    // sets when the left view shows up. default is UITextFieldViewModeNever

/**
 UITextField右边的视图
 */
@property(nullable, nonatomic,strong) UIView    *rightView;     // e.g. bookmarks button

@property(nonatomic)        UITextFieldViewMode  rightViewMode;   // sets when the right view shows up. default is UITextFieldViewModeNever

/**
 对齐方式
 */
@property (nonatomic) NSTextAlignment textAlignment;

/**
 键盘类型，默认为UIKeyboardTypeDefault
 */
@property (nonatomic) UIKeyboardType keyboardType;

/**
 是否为安全输入，默认为NO
 */
@property (nonatomic, assign, getter=isSecureTextEntry) BOOL secureTextEntry;


/**
 是否圆边，即圆角半径为高的一半
 */
@property (nonatomic, assign, getter=isRoundEdge) BOOL roundEdge;

/**
 最小缩放系数，0-1.0，默认为0.8
 */
@property (nonatomic, assign) CGFloat minimumScaleFactor;


/**
 状态，默认为PLTextFieldStateNormal
 */
@property (nonatomic, assign) PLTextFieldState state;

/** 
 textFiled代理 同UITextFiledDelegate 
 */
@property (nullable, nonatomic, weak) id<UITextFieldDelegate> delegate;


@property(nonatomic) UITextAutocapitalizationType autocapitalizationType; // default is UITextAutocapitalizationTypeSentences

@property(nonatomic) UITextAutocorrectionType autocorrectionType;         // default is UITextAutocorrectionTypeDefault
@property(nonatomic) UIReturnKeyType returnKeyType;                       // default is UIReturnKeyDefault (See note under UIReturnKeyType enum)
@property(nonatomic) BOOL enablesReturnKeyAutomatically;                  // default is NO (when YES, will automatically disable return key when text widget has zero-length contents, and will automatically enable when text widget has non-zero-length contents)

/**
 边框圆角半径，默认为圆边，即高的一半
 */
@property (nonatomic, assign) CGFloat borderCornerRadius;

#pragma mark - placeholder : 占位文字相关

@property(nullable, nonatomic, copy) NSString               *placeholder;


/**
 普通状态下，占位文字颜色
 */
@property(nullable, nonatomic, strong) UIColor              *placeholderColor;

/**
 编辑状态下，占位文字颜色
 */
@property(nullable, nonatomic, strong) UIColor              *placeholderHighlightColor;

/**
 错误状态下，占位文字颜色
 */
@property(nullable, nonatomic, strong) UIColor              *placeholderErrorColor;


@end
